package nc.tb.bc.table;

import java.util.ArrayList;

import nc.tb.bc.entryquery.EntryQuerySumRefPane;
import nc.tb.bccsaction.BcCsAction;
import nc.tb.form.vo.DimFormulaGroupVO;
import nc.ui.pub.bill.BillCellEditor;

public class EntrySumCellEditor extends BillCellEditor {
	private ArrayList<DimFormulaGroupVO> m_aldf = null;

	private BcCsAction m_bca = null;

	public EntrySumCellEditor(final EntryQuerySumRefPane csref, ArrayList<DimFormulaGroupVO> aldf,BcCsAction bca) {
		super(csref);
		m_aldf = aldf;
		m_bca=bca;
		csref.setBccsaction(m_bca);
		delegate = new EditorDelegate() {
			public void setValue(Object value) {
				csref.setValue((value != null) ? value.toString() : "");

			}

			// public Object getCellEditorValue() {
			// if (csref.getSelectedBusiObj() == null)
			// return csref.getText();
			// else
			// return csref.getSelectedBusiObj();
			// }
		};
	}

	public java.awt.Component getTableCellEditorComponent(javax.swing.JTable table, Object value,boolean isSelected, int row, int column) {
		((EntryQuerySumRefPane) editorComponent).setPosition(row, column);
		
		if (row > 0)
			((EntryQuerySumRefPane) editorComponent).setPk_eli(m_aldf.get(row - 1).getPrimaryKey());
		else ((EntryQuerySumRefPane) editorComponent).setPk_eli(null);
		
		delegate.setValue(value);
		return editorComponent;
	}
}
